package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IFriendshipLinkDao;
import com.financing.platform.dto.FriendshipLinkDTO;
import com.financing.platform.dto.GroupDTO;
import com.financing.platform.util.SqlName;

/**
 * 友情链接
 * @author caojiayao
 *
 */
@Repository("friendshipLinkDao")
public class FriendshipLinkDaoImpl extends BaseDaoImpl implements IFriendshipLinkDao {

	@Override
	public List<FriendshipLinkDTO> queryList(FriendshipLinkDTO friendshipLinkDTO) {
	try{
		return this.sqlMapClient.queryForList(SqlName.queryListFriendshipLink,friendshipLinkDTO);
	} catch (SQLException e) {
		log.error("Query all group error:",e);
		return Collections.emptyList();
	}
	}

	@Override
	public FriendshipLinkDTO get(Integer id) {
		try {
			return (FriendshipLinkDTO) this.sqlMapClient.queryForObject(SqlName.getFriendshipLink,id);
		} catch (SQLException e) {
			log.error("Query  group info error:",e);
			return null;
		}
	}

	@Override
	public Integer delete(Integer id) {
		try {
			return this.sqlMapClient.delete(SqlName.deleteFriendshipLink, id);
		} catch (SQLException e) {
			this.log.error("delete gorup error 1!",e);
			return 0;
		}
	}

	@Override
	public Integer update(FriendshipLinkDTO friendshipLinkDTO) {
		try {
			return this.sqlMapClient.update(SqlName.updateFriendshipLink, friendshipLinkDTO);
		} catch (SQLException e) {
			this.log.error("update gorup error 1!",e);
			return 0;
		}
	}

	@Override
	public Integer add(FriendshipLinkDTO friendshipLinkDTO) {
		try {
			return (Integer) this.sqlMapClient.insert(SqlName.addFriendshipLink, friendshipLinkDTO);
		} catch (SQLException e) {
			this.log.error("update gorup error 1!",e);
			return -1;
		}
	}

}
